﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Security;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Threading;

namespace OmniKits.Windows
{
    public static class ViewManager
    {
        private static Lazy<bool> _LazyIsInDesignMode = new Lazy<bool>(() =>
        {
            var designDPD = DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(DependencyObject));
            return (bool)designDPD.Metadata.DefaultValue;
        });
        public static bool IsInDesignMode => _LazyIsInDesignMode.Value;

        public static void ForceRender(DispatcherPriority priority = DispatcherPriority.Render)
        {
            if (priority > DispatcherPriority.Render || priority < DispatcherPriority.SystemIdle)
                throw new ArgumentOutOfRangeException(nameof(priority));

            Dispatcher.CurrentDispatcher.Invoke((Action)(() => { }), priority);
        }
    }
}
